<?php
/**
 * Created by PhpStorm.
 * User: lili
 * Date: 2018/12/29
 * Time: 10:50
 * 公共函数
 */

use \system\library\Session;
use \system\library\Cookie;
use \system\core\config\Config;

if (!function_exists('config')) {

    function config($key,$value=''){
         
        if (empty($value)){
            Config::get($key);
        }else{
            Config::set($key,$value);
        }
    }

}

if (!function_exists('session')) {
    
    function session($key,$value=''){
        $session = Session::getInstance();
        if (empty($value)){
            $session->get($key);
        }else{
            $session->set($key,$value);
        }
    }
    
}

if (!function_exists('cookie')) {

    function cookie($key,$value=''){
        $cookie = Cookie::getInstance();
        if (empty($value)){
            $cookie->get($key);
        }else{
             
            $cookie->set($key,$value);
        }
    }

}


if (!function_exists('cache')) {

    function cache($key,$value='',$expire = 0){
        $cache = \system\library\Cache::getInstance();
        if (empty($value)){
            $cache->get($key);
        }else{

            $cache->set($key,$value,$expire);
        }
    }

}


function dump($var){
    var_dump($var);
}




// 作用范围隔离

/**
 * include
 * @param  string $file 文件路径
 * @return mixed
 */
function __include_file($file)
{
    return include $file;
}

/**
 * require
 * @param  string $file 文件路径
 * @return mixed
 */
function __require_file($file)
{
    return require $file;
}